
const TechCaseDetail = {
    getCaseDetails: function () {
        let _this = this;
        let id = common.getQueryString("id")
        ajax_get(host + `/ajax/projectDetail/${id}`,
            true,
            {},
            (res) => {
                res = JSON.parse(res)
                console.log(res)
                if (res.detail) {
                    const { detail, next, prev } = res
                    $(".detail-name").text(detail.title)
                    $(".detail-info span:nth-child(1)").text("发布日期：" + detail.publish_time)
                    $(".detail-info span:nth-child(2)").text("浏览次数：" + detail.view_num)
                    let arrEntities = {
                        'lt': '<',
                        'gt': '>',
                        'nbsp': ' ',
                        'amp': '&',
                        'quot': '"'
                    };
                    detail.content = detail.content.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
                        return arrEntities[t]
                    })
                    $(".currentName").html(`<a href="case-detail.html?id=${detail.id}">${detail.title}</a>`)
                    $(".detail-desc").html(detail.content)
                    if(prev && prev.id) {
                        $(".detail-related-prev").append(`<a href='case-detail.html?id=${prev.id}'>${prev.title}</a>`)
                    }
                    if(next && next.id) {
                        $(".detail-related-next").append(`<a href='case-detail.html?id=${next.id}'>${next.title}</a>`)
                    }
                    
                }
            },
            err => {
                console.log(err)
            }
        );
    }
}


$(function () {
    common.init()
    common.getPhoneInfo()
    common.getBanner("project")
    common.getFootProductCatList()
    common.getFootInfo()
    TechCaseDetail.getCaseDetails()
})